package univer.oko.gui;

import javax.swing.*;
import javax.swing.table.DefaultTableColumnModel;
import javax.swing.table.DefaultTableModel;

/**
 * @author Eduard Dudar
 *         DATE: 24.07.2005
 *         Time: 23:51:20
 */
public class CDDefaultTable extends JTable {
    public CDDefaultTable(int columns, DefaultTableColumnModel cmodel) {
        super(new DefaultTableModel(1, columns), cmodel);
        this.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        this.setRowHeight(20);
    }

    public DefaultTableModel getTableModel() {
        return (DefaultTableModel) getModel();
    }

    public void addRow() {
        this.getTableModel().addRow(new Object[]{});
    }

    public void removeRow() {
        this.getTableModel().removeRow(this.getTableModel().getRowCount() - 1);
    }

    public void removeRow(int index) {
        this.getTableModel().removeRow(index);
    }

}
